﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Portal.Xml.Utility;

namespace Portal.Systems.Model
{
    public class WorkflowControlCls
    {
        public string WorkflowControlId;
        public string Title;
        public string Description;
        public string WorkflowDefId;
        public string AssetCode;
        public string DataLanguageId;
        public string DataLanguageCode;
    }

    public class WorkflowControlParser
    {
        public static WorkflowControlCls CreateInstance()
        {
            //tao 1 class trang....
            WorkflowControlCls oWorkflowControlCls = new WorkflowControlCls();
            return oWorkflowControlCls;
        }

        public static WorkflowControlCls ParseFromXml(string XmlData)
        {
            DataSet ds = XmlUtility.GetDataSetFromXml(XmlData);
            WorkflowControlCls oWorkflowControlCls = ParseFromDataRow(ds.Tables[0].Rows[0]);
            return oWorkflowControlCls;
        }


        public static WorkflowControlCls ParseFromDataRow(DataRow dr)
        {
            WorkflowControlCls OWorkflowControlCls = new WorkflowControlCls();
            OWorkflowControlCls.WorkflowControlId = (string)dr["WorkflowControlId"];
            OWorkflowControlCls.Title = (string)dr["Title"];
            try
            {
                OWorkflowControlCls.Description = (string)dr["Description"];
            }
            catch { }
            OWorkflowControlCls.WorkflowDefId = (string)dr["WorkflowDefId"];
            OWorkflowControlCls.AssetCode = (string)dr["AssetCode"];
            OWorkflowControlCls.DataLanguageId = (string)dr["frkDataLanguageId"];
            OWorkflowControlCls.DataLanguageCode = (string)dr["DataLanguageCode"];

            return OWorkflowControlCls;
        }

        public static WorkflowControlCls[] ParseFromDataTable(DataTable dtTable)
        {
            WorkflowControlCls[] WorkflowControls = new WorkflowControlCls[dtTable.Rows.Count];
            for (int iIndex = 0; iIndex < dtTable.Rows.Count; iIndex++)
            {
                WorkflowControls[iIndex] = ParseFromDataRow(dtTable.Rows[iIndex]);
            }

            return WorkflowControls;
        }
    }
}





